import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Studentvo } from '../vo/studentvo';

@Injectable()
export class StudentService {

  constructor(private http:HttpClient) { }


  private getAnObjectUrl="http://localhost/getAnObject";
  getAnObject(){
    return this.http.get(this.getAnObjectUrl).toPromise();
  }

  private addStudengInfoUrl="http://localhost/SaveStudentInfo";
  addStudengInfo(svo:Studentvo){
    let p={
      "studentid":svo.studentid,
      "xm":svo.xm,
      "sfzh":svo.sfzh,
      "xh":svo.xh
    }

    return this.http.post(this.addStudengInfoUrl,p).toPromise();
  }

  private getStudentListUrl="http://localhost/getStudentList";
  getStudentList(){
    return this.http.get(this.getStudentListUrl).toPromise();
  }

  private getSingleStudentUrl="http://localhost/getSingleStudentById";
  getSingleStudent(id:string){

    let p={
      "studentid":id
    }
    return this.http.post(this.getSingleStudentUrl,p).toPromise();
  }

  private deleteStudentUrl="http://localhost/deleteStudent";
  deleteStudent(id:string){
    let p={
      "studentid":id
    }
    return this.http.post(this.deleteStudentUrl,p).toPromise();
  }

}
